// https://vant-contrib.oschina.io/vant/#/zh-CN/
<template>
  <div class="handle">
    <div class="title">
      <van-search placeholder="请输入搜索关键词" />
      <van-icon name="shopping-cart-o" color="#ffffff" @click="skip_shoppingCart"/>
    </div>
    <van-swipe :autoplay="5000">
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img v-lazy="image" />
      </van-swipe-item>
    </van-swipe>
    <div class="button">
      <van-button round type="primary" color="#ff5555" @click="skip_newProduct">新品上市</van-button>
      <van-button round type="primary" color="#ff5555" @click="skip_secendHand">二手商城</van-button>
    </div>

    <!-- 热销单品 -->
    <van-row>
      <van-col span="24" color="rgba(89, 89, 89, 1)">热 销 单 品</van-col>
    </van-row>

    <van-grid :border="false" :column-num="4">
      <van-grid-item v-for="(item, index) in list1" :key="index">
        <van-image :src="listImg1[index]" round />
        <van-row>
          <van-col span="24" color="rgba(89, 89, 89, 1)">{{item.name}}</van-col>
        </van-row>
      </van-grid-item>
    </van-grid>

    <!-- 家庭常用 -->
    <van-row class="often">
      <van-col span="24" color="rgba(89, 89, 89, 0.8)">家 庭 常 用</van-col>
    </van-row>

    <van-grid :border="false" :column-num="4" class="usually">
      <van-grid-item v-for="(item, index) in list2" :key="index">
        <van-image :src="listImg2[index]" round />
        <van-row>
          <van-col span="24" color="rgba(89, 89, 89, 1)">{{
            item.name
          }}</van-col>
        </van-row>
      </van-grid-item>
    </van-grid>
    <Footer></Footer>
  </div>
</template>

<script>
import Footer from "../../components/Footer.vue";
import Vue from 'vue';
import { Lazyload } from 'vant';

import {getShop} from '../../api/index'

Vue.use(Lazyload);



export default {
  components: {
    Footer,
  },
  data() {
    return {
      list1: [],
      list2: [],
      images: [
        require('../../../public/swiper/4.png'),
        require('../../../public/swiper/5.png'),
        require('../../../public/swiper/6.png'),
      ],
      listImg1:[
        require('../../../public/shangcheng/1.png'),
        require('../../../public/shangcheng/2.png'),
        require('../../../public/shangcheng/3.png'),
        require('../../../public/shangcheng/4.png'),
      ],
      listImg2:[
        require('../../../public/shangcheng/5.png'),
        require('../../../public/shangcheng/6.png'),
        require('../../../public/shangcheng/7.png'),
        require('../../../public/shangcheng/8.png'),
      ],
    };
  },
  created() {
    this.$store.commit('setNum', 1)
    
    this.init()
  },
  methods:{
    async init(){
      let {data,meta: { status, msg }} = await getShop()
      // console.log(data);
      this.list1 = data.slice(0,4)
      this.list2 = data.slice(4)
    },
    skip_shoppingCart(){
      this.$router.push('/shopping_cart')
    },
    skip_newProduct(){
      this.$router.push('/new_product')
    },
    skip_secendHand(){
      this.$router.push('/secend_hand')
    }
  }
};
</script>

<style lang="less" scoped>
.handle {
  width: 100%;
  .title {
    width: auto;
    background: #ff5555;

    padding: 0;
    padding-top: 16px;
    display: flex;
    .van-search {
      width: 600px;
      height: 54px;
      border-radius: 5px;
      margin-left: 76px;
      margin-bottom: 10px;
      padding: 0;
      background-color: #f7f8fa;
      .van-cell {
        padding: 0;
      }
    }
    .van-icon {
      padding: 10px 20px 0 16px;
      font-size: 42px;
    }
  }
  
  .van-swipe{
    height: 302px;
    img{
      width: 750px;
      height: 302px;
    }
  }
  /deep/.van-swipe__indicator--active {
    background-color: #ff5654;
  }

  .button {
    color: #ffffff;
    margin: 0 82px;
    margin-top: 28px;
    display: flex;
    justify-content: space-between;
    .van-button {
      font-size: 30px;
      width: 250px;
      height: 76px;
      padding: 22px 52px;
    }
  }
  .van-row {
    text-align: center;
    margin: 20px 0;
    .van-col {
      font-size: 26px;
    }
  }
  .van-grid {
    margin: 0 20px;
    // margin-bottom: 55px;
    padding: 0;
    box-shadow: rgba(153, 153, 153, 0.5) 0px 0px 14px 0px;
    /deep/.van-grid-item__content--center {
      padding: 0 15px;
      padding-top: 36px;
      .van-row {
        margin-top: 25px;
        margin-bottom: 42px;
      }
    }
    /deep/.van-image__img {
      width: 140px;
      height: 140px;
    }
  }
  .usually {
    margin-bottom: 110px;
  }
  .often {
    margin: 30px 0;
  }

  
}
</style>